﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace Jhw.Common.Helper
{
    public static class StringHelper
    {
        /// <summary>
        /// 转换成JsonString，不带换行
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public static string ToJsonString(this object o, int maxDepth = 3)
        {
            if (o == null) {
                return string.Empty;
            }
            return JsonConvert.SerializeObject(o, Formatting.None, new JsonSerializerSettings() { MaxDepth = maxDepth });
        }
    }
}
